import frappe

def has_app_permission(user=None):
    """检查用户是否有EAM应用权限
    参数:
        user (str|None): 用户ID，可为空；为空时默认读取当前会话用户
    返回:
        bool: 是否具备访问EAM应用的权限
    """
    roles = frappe.get_roles(user) if user else frappe.get_roles()
    allowed_roles = ['System Manager', 'EAM Manager', 'Equipment Operator']
    return any(role in allowed_roles for role in roles)